using System.Collections.Generic;
using Belmost4PDA.Constants;
using Belmost4PDA.Fasade;

namespace Belmost4PDA.Logic
{
    public class CmdDelete:AbstractCommand
    {
        public CmdReadData cmd;//=new CmdReadData(true);
        public DataProcesser processer = new DataProcesser(DataProcesser.Action.Delete);
        public override void Execute(ref AbstractState currentState, ref AbstractControl TopControl,
                                     ref List<AbstractMapper> AllMappers)
        {
            if(currentState.AskToDo(this))
                if (processer.Delete(currentState.WorkedParam.TableName, ((Control_Grid)(TopControl.GetGrid())).GetIdFieldName(), ((Control_Main)(TopControl)).GridIDValue))
                {
                    cmd = new CmdReadData(true);
                    InterfaceDispatcher.ExecCommand(cmd);
                    
                }
            
        }

        public override CommandID GetID()
        {
            return CommandID.Delete;
        }
    }
}
